/**
 * 转成链表，寻找环的入口
 * @param {number[]} nums
 * @return {number}
 */
var findDuplicate = function (nums) {
    let slow = 0, fast = 0;

    do {
        slow = nums[slow]
        fast = nums[nums[fast]]
    } while (slow !== fast)

    slow = 0;
    while (slow !== fast) {
        slow = nums[slow]
        fast = nums[fast]
    }

    return slow
};